/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cleaner;

import java.io.IOException;

/**
 *
 * @author Denis Adyakov aka DoZENT
 */
public class Main {

    private static String COMMAND_HELP = "help";
    private static String COMMAND_CLEAN = "clean";
    private static String ERRORINPUT = "Illegal command line using. Try Cleaner.jar help to get commands description";


    /**
     *
     * @param args
     * clean: clean directory [dir] and recycle bin [recyclebin]
     *        usage: java -jar Cleaner.jar clean C:\SomeDir C:\Recycle
     * <br>
     * help:  display commands description
     */
    public static void main(String[] args) {

        System.out.println("Cleaner");


        if (args.length > 0){

            //Command get help
            if (args[0].equals(COMMAND_HELP)){
                System.out.println("Cleaner commands list:");
                System.out.println("clean: Clean directory. Command usage: Cleaner.jar [clean] [dir] [recyclebin folder]");
                System.out.println("help: Get commands description");
                
                try{
                    System.in.read();
                }
                catch (IOException ex)
                {
                    ex.printStackTrace();
                }

            }

            //Command clean
            else if (args[0].equals(COMMAND_CLEAN)){
                if (args.length > 2){
                    //new fileworker based on directory from command line argument
                    FileWorker fileworker = new FileWorker (args[1], args[2]);
                    fileworker.CleanFolder();
                    fileworker.CleanRecycleBin();
                }
                else{
                    System.out.println (ERRORINPUT);
                }

            }
            else {
                System.out.println (ERRORINPUT);
            }
            
        }
        else
        {
            System.out.println (ERRORINPUT);
        }


    }




}
